package com.sh.mapper;

import com.sh.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {

    //根据用户名查询用户
    @Select("select * from user where username=#{username}")
    User findByUserName(String username);

    @Insert("insert into user(username,password,create_time,update_time)" +
            "  values(#{username},#{password},#{createTime},#{updateTime})")
    void add(User user);

    @Select("select count(*) from user where username=#{username} and password=#{password}")
    int login(User u);

    @Update("update user set nickname = #{nickname},email =#{email},update_time=#{updateTime}  where id=#{id}")
    void update(User user);

    @Update("update user set user_pic=#{userPic}  ,update_time=#{updatTime} where id=#{id}")
    void updateavtar(User user);

    @Update("update user set password=#{password} where id=#{id}")
    void updatePwd(User u);
}
